package com.gem.day13;

import java.io.File;
import java.io.FilenameFilter;

/**自定义规则过滤器*/
public class SuffixFilter implements FilenameFilter {

	private String suffix;

	public SuffixFilter(String suffix) {
		this.suffix = suffix;
	}

	@Override
	public boolean accept(File dir, String name) {
		File file = new File(dir, name);
		if (file.isDirectory()) {
			return false;
		}
		//此处过滤规则可以任意定制
		if (file.getName().endsWith(suffix)) {
			return true;
		}
		return false;
	}
}
